package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024 —03 —04
 * Time: 20:57
 */
public class BorrowOperation implements IOPeration{
    public void work(Booklist booklist) {
        System.out.println("借阅图书");
        /*
         * 1：借哪本书
         * 2：借的书有没有
         * 3：借阅的方式
         * */

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要借阅哪本书");
        String name = scanner.nextLine();
        int currentSize = booklist.getUsedsize();
        for (int i = 0; i < booklist.getUsedsize(); i++) {
            Book book = booklist.getBook(i);//不太懂//把books传给book   books已经完成对象的实例化，在用book去点出get方法，在进行字符串的比较
            if (book.getName().equals(name)){//getName怎么实现覆盖的啊啊啊啊啊 //拿捏
                book.setIsborrowed(true);
                System.out.println("借阅成功");
                System.out.println(book);
                return;
            }
        }

        System.out.println("你节约的图书不存在");
    }


}
